package jmine.tec.web.wicket.component;

import jmine.tec.web.wicket.component.enumx.CSSClass;
import jmine.tec.web.wicket.component.enumx.DefaultCSSClassEnum;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 * TextField em formato de Panel para poder adicionar em outros lugares
 * 
 * @author Rafael Volpato
 * @date Dec 27, 2011
 * @param <T> model type
 */
public class InlinedTextField<T> extends Panel {

    private TextField<T> textField;

    /**
     * C'tor
     * 
     * @param id String
     * @param model model
     */
    public InlinedTextField(String id, IModel<T> model) {
        this(id, model, DefaultCSSClassEnum.TEXT);
    }

    /**
     * C'tor
     * 
     * @param id String
     * @param model model
     * @param classes classes
     */
    public InlinedTextField(String id, IModel<T> model, CSSClass... classes) {
        super(id);
        this.textField = new TextField<T>("text", model);
        for (CSSClass cssClass : classes) {
            this.textField.add(new AttributeAppender("class", new Model<String>(cssClass.getName()), " "));
        }
        this.add(this.textField);
    }

    /**
     * @return the textField
     */
    public TextField<T> getTextField() {
        return this.textField;
    }
}